import Variable from "../../constants/index";

Page({
  data: {
    avatarUrl: 'https://game.gtimg.cn/images/lol/act/a20241008superfan/bg_01.jpg', // 头像地址
    userName: '王*颜',
    userAddress: '月亮湾小区服务站',
    onlineTime: '您已累计在线 60 小时',
    walletAmount: 300,
    orderCount: 4
  },
  // 点击跳转个人详情页
  toUserInfo(){
    wx.navigateTo({
      url:'/pages/info/info'
    })
  },
  // 点击头像更换头像
 async changeAvatar(){
    const result = await wx.chooseMedia({
      count:1,
      mediaType:['image']
    })
    console.log(result);    
    if(result.tempFiles.length){
      this.setData({
        avatarUrl:result.tempFiles[0].tempFilePath
      })
    }
  },
  // 只要页面展示就执行
  onShow(){
       // 有资料 在本地存储 
    const avatar = wx.getStorageSync(Variable.AVATAR_KEY)
    const nickname = wx.getStorageSync(Variable.NICKNAME_KEY)
    this.setData({
      avatarUrl:avatar,
      userName:nickname
    })
  },
  goToWallet: function () {
    wx.navigateTo({
      url: '/pages/wallet/wallet'
    });
  },
  goToOrderStats: function () {
    wx.navigateTo({
      url: '/pages/orderStats/orderStats'
    });
  },
  goToMyEvaluation: function () {
    wx.navigateTo({
      url: '/pages/myEvaluation/myEvaluation'
    });
  },
  goToMyTransport: function () {
    wx.navigateTo({
      url: '/pages/myTransport/myTransport'
    });
  },
  goToMyChild: function () {
    wx.navigateTo({
      url: '/pages/myChild/myChild'
    });
  },
  goToRequestHelp: function () {
    wx.navigateTo({
      url: '/pages/requestHelp/requestHelp'
    });
  },
  goToHelpAndCs: function () {
    wx.navigateTo({
      url: '/pages/helpAndCs/helpAndCs'
    });
  }
});